package com.lambda;

import java.util.function.Supplier;

/**
 * Created by
 * supplier生成数据
 * @author touni
 * @date 2019/4/29
 * @time 10:43
 */
public class DemoSupplier {

    public static String getString(Supplier<String> sup){
        return sup.get();
    }

    //定义一个方法，用来获取最大值，使用lambda表达式
    public static Integer getInteger(Supplier<Integer> supplier){

        return supplier.get();
    }





    public static void main(String[] args) {
        System.out.println(getString(()-> "ksjdjdjdjdjdj" ));

        Integer[] integers = {52,56,96,85,100,36,96};
        System.out.println(getInteger(() ->{
            //获取数组的最大值
            int max = integers[0];
            for (int i :integers){ if (i > max){max = i;} }
            return max;
        }));








    }




}
